#coding=utf-8
import mysql_connect_henghe
# 进行数据库查询salt加密后的密码
def password(mobile):
    try:
        connect = mysql_connect_henghe.mysql_connect()[0]  # connect是由connect_mysql函数返回的第一个值
        cursor = connect.cursor()
        # SQL 查询语句
        sql = "SELECT password from gdgyun_community.community_user WHERE mobile ="+mobile
        sql_id = "SELECT id from gdgyun_community.community_user WHERE mobile =" + mobile
        sql_nickname = "SELECT nick_name from gdgyun_community.community_user WHERE mobile =" + mobile
        # 执行sql语句
        cursor.execute(sql)
        result = cursor.fetchall()
        connect.commit()  # 实例提交命令
        password = str(result[0][0])
        # 执行sql语句
        cursor.execute(sql_id)
        id = cursor.fetchall()
        connect.commit()  # 实例提交命令
        user_id = str(id[0][0])
        # 执行sql语句
        cursor.execute(sql_nickname)
        nickname = cursor.fetchall()
        connect.commit()  # 实例提交命令
        NickName = str(nickname[0][0])
        return password,user_id,NickName   #返回密码和user_id、昵称
    except:
        return '0','0','0'  #查询出错时全部返回0
def community_num(mobile):
    try:
        connect = mysql_connect_henghe.mysql_connect()[0]  # connect是由connect_mysql函数返回的第一个值
        cursor = connect.cursor()
        # SQL 查询语句
        sql = "SELECT community_no from gdgyun_community.community_user WHERE mobile ="+mobile
        # 执行sql语句
        cursor.execute(sql)
        result = cursor.fetchall()
        connect.commit()  # 实例提交命令
        community_no = str(result[0][0])
        return community_no   #返回密码和user_id、昵称
    except:
        return '0'  #查询出错时全部返回0

if __name__ == '__main__':
    community_num('13800010082')